﻿<div id="list" />
@section footer{
    <script type="text/javascript">
        var columns = [
              { hide: true, display: '公司编号', name: 'CustomerId' }
            , { display: '公司名称', name: 'CustomerName', align: 'left', width: 130, minWidth: 60 }
            , { display: '简称', name: 'ShortName', align: 'left', width: 141, minWidth: 60 }
            , { display: '助记码', name: 'MnCode', align: 'left', width: 141, minWidth: 60 }
            , { display: '公司地址', name: 'Address', align: 'left', width: 141, minWidth: 60 }
            , { display: '联系电话', name: 'Phones', align: 'left', width: 141, minWidth: 60 }
            , { display: '联系人', name: 'Contract', align: 'left', width: 141, minWidth: 60 }
        ];
        var toolbaritems = [
              { id: "C", text: '添加', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/add.png")' }
            , { line: true }
            , { id: "R", text: '明细', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/detail.png")' }
            , { line: true }
            , { id: "U", text: '修改', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/edit.png")' }
            , { line: true }
            , { id: "D", text: '删除', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/delete.png")' }
        ];
        $(function () {
            grid = $("#list").ligerGrid({
                url: '@Url.Action("GetGrid")', columns: columns, dataAction: 'server', pageSize: 20, sortName: 'CustomerId', sortOrder: 'asc',
                rownumbers: true, width: '98%', height: '100%', heightDiff: -10, checkbox: false, toolbar: {}
            });
            if (grid.toolbarManager)
                grid.toolbarManager.set("items", toolbaritems);
        });

        function toolbarclick(item) {
            var width = 800;
            var height = 400;
            switch (item.id) {
                case "C":
                    child = $.ligerDialog.open({ width: width, height: height, url: '@Url.Action("Create")', showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title: '客户新增' });
                    break;
                case "R":
                    var rows = grid.getSelected();
                    if (!rows) { $.ligerDialog.warn('请选择行!'); return }
                    child = $.ligerDialog.open({ width: width, height: height, url: '@Url.Action("Detail")' + '?keys=' + rows.CustomerId.toString(), showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title: '客户更新' });
                    break;
                case "U":
                    var rows = grid.getSelected();
                    if (!rows) { $.ligerDialog.warn('请选择行!'); return }
                    child = $.ligerDialog.open({ width: width, height: height, url: '@Url.Action("Update")' + '?keys=' + rows.CustomerId.toString(), showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title: '客户更新' });
                    break;
                case "D":
                    var rows = grid.getSelecteds();
                    if (rows.length == 0) { $.ligerDialog.warn('请选择行!'); return }
                    $.ligerDialog.confirm("确认删除吗", function (r) {
                        if (r) {
                            LG.gridpost('@Url.Action("Delete")', { data: JSON.stringify(rows) }, grid);
                        }
                    });
                    break;
            }
        }
        
    </script>
}
